package com.maxlen.goods.controller.reception;

import com.maxlen.common.utils.R;
import com.maxlen.goods.entity.dto.SearchHomeDTO;
import com.maxlen.goods.entity.dto.SkuItemDTO;
import com.maxlen.goods.service.SkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * 前台接口
 */
@RestController
@RequestMapping("/goods/reception")
public class ReceptionController {

    @Autowired
    private SkuInfoService skuInfoService;

    /**
     * 通过 skuId 获取商品详情页的所有信息
     * @param skuId
     * @return
     */
    @GetMapping("/getSkuInfo/{skuId}")
    public R getSkuInfo(@PathVariable("skuId") Long skuId) throws ExecutionException, InterruptedException {
        SkuItemDTO skuItemDTO = skuInfoService.getSkuInfo(skuId);
        return R.ok().put("data", skuItemDTO);
    }

    /**
     * 首页获取商品
     * @return
     */
    @GetMapping("/getSkuInfoHome")
    public R getSkuInfoHome(){
        return skuInfoService.getSkuInfoHome();
    }

}
